package com.mapper;

import com.pojo.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {
    @Select("SELECT * FROM category")
    List<Category> findAll();

    @Insert("INSERT INTO category(name, parent_id, status) VALUES(#{name}, #{parentId}, #{status})")
    void insert(Category category);

    @Select("SELECT * FROM category WHERE id = #{id}")
    Category selectById(Long id);

    @Update("UPDATE category SET name=#{name}, parent_id=#{parentId}, status=#{status} WHERE id=#{id}")
    void update(Category category);

    @Delete("DELETE FROM category WHERE id = #{id}")
    void delete(Long id);
}
